<template>
	<!-- v-if="goodsInfo" -->
	<view class="goods-card">
		<uni-section type="line" title="货架">
		</uni-section>
		<view class="body">
			<view class="img">
				<image :src="goodsInfo.goods_img" mode="scaleToFill"></image>
			</view>
			<view class="box">
				<div class="tltle">{{goodsInfo.goods_title}}</div>
				<div class="desc">{{goodsInfo.goods_description}}</div>
				<div class="tags">
					<uni-tag class="tag" text="推荐" type="error" size="mini" circle="true" />
					<uni-tag class="tag" text="较多收藏" type="error" size="mini" circle="true" />
				</div>
				<!-- 使用伪元素 来搞定单位 -->
				<div class="price">
					<span class="now">0</span>
					<span class="del">{{goodsInfo.goods_price}}</span>
				</div>
				<div class="show-disk-link" @click="showDiskLink">查看链接</div>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "goods-card",
		data() {
			return {};
		},
		props: ['goodsInfo'],

		mounted() {},
		methods: {
			showDiskLink() {
				let diskObject = {
					url: this.goodsInfo.disk_url,
					key: this.goodsInfo.disk_key,
					type: this.goodsInfo.disk_type,
				}
				uni.$emit('getDiskInfo', diskObject)
			}
		}
	}
</script>

<style lang="less">
	.goods-card {
		margin: 20rpx;
	}

	.body {
		display: flex;
		position: relative;
		margin: 20rpx 0;
		padding: 20rpx;
		border-radius: 20rpx;
		box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);

		.img {
			flex: 4;
			display: flex;
			justify-content: center;
			align-items: center;
			//对齐方式 块级作用域的对齐方式 对一些出头字母的控制 例如 gjp 都是有尾巴露在外边
			vertical-align: bottom;

			image {
				width: 240rpx;
				height: 240rpx;
				border: 1px solid #f40;
				border-radius: 20rpx;
			}
		}

		.box {
			flex: 6;

			margin-left: 10rpx;

			.tltle {
				margin: 10rpx;
				font-size: 40rpx;
				font-weight: 900;
				color: #000;
			}

			.desc {
				margin: 10rpx;
				color: #222;
				font-size: 26rpx;
				font-weight: 400;
			}

			.tags {
				margin: 10rpx;

				.tag {
					margin: 2rpx 10rpx;
					border-radius: 20rpx;
				}
			}

			.price {
				margin: 10rpx;

				.now {
					color: #f40;
					font-size: 28rpx;

					&::before {
						content: '￥';
						font-size: 24rpx;
						color: #f40;
					}
				}

				.del {
					margin-left: 10rpx;
					color: #666;
					font-size: 28rpx;
					text-decoration: line-through;

					&::before {
						content: '￥';
						font-size: 24rpx;
						color: #666;
					}
				}
			}

			.show-disk-link {
				position: absolute;
				right: 0;
				bottom: 30rpx;
				padding: 10rpx;
				border-radius: 20rpx 0 0 20rpx;
				font-size: 30rpx;
				color: #fff;
				background-color: #f40;
			}

		}
	}
</style>
